/*************************************************************************
	> File Name: dymamic_main.c
	> Author: Maureen 
	> Mail: Maureen@qq.com 
	> Created Time: 日  8/29 15:09:06 2021
 ************************************************************************/

#include <stdio.h>
#include <dlfcn.h>

int main(int argc, char *argv[]) {
    void *dl = NULL;
    int (*add)(int a, int b);
    dl = dlopen("./module/lib/libmaureen.so", RTLD_LAZY);
    if (dl == NULL) {
        printf("so loading error.\n");
        return 1;
    }

    add = (int (*)(int, int))dlsym(dl, "add");
    if (dlerror() != NULL) {
        printf("func load error.\n");
        return 1;
    }

    printf("%d\n", add(1, 2));

    return 0;
}
